package Practice.Practice_02.UserManagementSystem;

import java.util.Objects;
import java.util.Scanner;

public class AddUser {
    public static void add(Person[] person){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要增添的用户名");
        String name = sc.next();
        System.out.println("请输入要增添的用户密码");
        String password = sc.next();
        System.out.println("请输入要增添的用户邮箱");
        String email = sc.next();
        System.out.println("请输入要增添的用户权限");
        String power = sc.next();
        for(int i = 0; i < person.length; i++){
            if(Objects.equals(person[i].getName(), name)){
                System.out.println("该用户已存在！");
                break;
            }else if(Objects.equals(person[i].getName(), "-1")){
                person[i].setId(i);
                person[i].setName(name);
                person[i].setPass(password);
                person[i].setEmail(email);
                person[i].setPower(power);
                System.out.println("添加成功。。。");
                break;
            }
        }
    }
}
